package blog.sys.service;

import blog.sys.data.user.UserInfoData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pub.dao.GeneralDao;

@Service
@Transactional(readOnly = true)
public class UserInfoService {

    public UserInfoData onGetUserInfoShowService(Integer userId) {
        String sql = "SELECT u.id,u.name,u.nickname,u.info,u.avatar,u.sex,(select count(*) from t_user_friend f WHERE f.fid = u.id or f.uid = u.id) friendNum,(select count(*) FROM t_release_content r WHERE r.user_id = u.id) as releaseNum FROM t_user u WHERE u.id = ?";
        UserInfoData data = generalDao.queryValue(UserInfoData.class,sql,userId);
        return data;
    }

    @Autowired
    private GeneralDao generalDao;
}
